<%--
 *  File:    RemedyReason.jsp
 *  @Author: Kent Zhong
 *  Date:    11/12/2002 16:27
 *
 *  Copyright (C) 2000 - 2003 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>     
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>
<%@ page import="com.oval.util.*" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/oval-tag.tld" prefix="oval" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>



<%--  setting logger --%>
<%
  	Category cat = Category.getInstance("jsp.BrandSummary");  
%>

<%--  variant and initialization --%>
<%
	String strModuleName = "PCM";
  	String strTableName = "jpovprodbrand";
	String privilegeCode = "10209";
  	
  	//get current userinfo
  	HashMap CurUserInfo = (HashMap)session.getAttribute("userinfo");
	int orgid = ((Integer)CurUserInfo.get("orgid")).intValue();
  	cat.debug("The userinfo is :"+CurUserInfo);
  	cat.info("enter my page");
  
%>

<%--  include files list --%>

<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/FrmDefault.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>

<%int LangNums = ConstantProp.multiLangNumber;%>
<html>
<head>
<title>ProductBrand</title>
<PageFlow:CheckPageFlow pageName="prodbrandsummary"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="../../css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="../../js/FuncLib.js"></script>
<script language="JavaScript" src="../../js/ScriptLib.js"></script>
<%@ include file="/inc/SummaryDivision.inc" %>
<%@ include file="/inc/InitEdit.inc" %>
<script language="JavaScript">
   function page_summary(actionvalue,orderbyname)
		{
	  	var editform = summaryPrepare(cform,actionvalue,orderbyname);
	  	editform.action = "BrandSummary.jsp";
	  	editform.target = "_self";
	  	isRunning = true;
	  	editform.submit();  
		}
		
function page_codechange()
{
	var obj1 = cform.brandcodetemp;
	if(Trim(obj1.value) == ""){
		alert('<%=message.getMessageDesc("J_BRANDCODE_NOT_NULL")%>');
		return;
	}
	
  for(var i=1;i < Number(cform.nums.value)+1;i++)
  {
    var obj=eval("cform.brandcodes"+i);
    if(obj.value == Trim(obj1.value))
    {
      alert('<%=message.getMessageDesc("J_BRANDCODE_EXISTED")%>');
      cform.brandcodetemp.value="";
      return;
    }
  }
 
}
function page_add()
{

  if(!checkALLElems(document.getElementById("newdetail"))) return;
  page_copydesc();
  cform.actionname.value = "add";
  cform.target = "_self";
  isRunning = true;
  cform.submit();
}
function page_save()
{
 if(!checkALLElems(document.getElementById("olddetail"))) return;
  page_copydesc();
  cform.actionname.value = "save";
  cform.target = "_self";
  isRunning = true;
  cform.submit();
}
function page_delete()
{
  if(isNullChecked(cform.brandcodes)) 
  {
    alert('<%=message.getMessageDesc("PLEASE_SELECT")%>');
    return;
  }
  if(!confirm('<%= message.getMessageDesc("ARE_YOU_SURE_DEL") %>'))
     return;
            
  cform.actionname.value = "delete";
  cform.target = "_self";
  isRunning = true;
  cform.submit();
}


function page_mulilang(columnname,label,num,need,entitycode,orgid)
{
  
  if(popwindow!=null)
    popwindow.close();
  var strurl="../../common/Lang.jsp?<%= OvalTools.randomURL() %>&form=cform&module=PCM&mlctype="+label+"&nativelanguage="+need+"&schema=v_jpproductbrand&qlname=selectbycode&orgid="+orgid+"&entitytype="+columnname+"&contentid=productbrandid&entitycode="+entitycode+"&colindex="+num;
  var strStatus= "height=250, width=250,top=100,left=100,toolbar=n0, menubar=no, scrollbars=no, resizable=no, location=no, status=no";
  popwindow=window.open(strurl, "newwindow",strStatus);
}

function page_copydesc()
{
	for(var i=0;i< <%=LangNums%>;i++)
  {
    var obj0=eval("cform.brandname"+i);
    if(obj0.value != "")
    var objtemp=obj0.value;
  }
  
  for(var i=0;i< <%=LangNums%>;i++)
  {
    var obj=eval("cform.brandcode"+i);
    var obj1=eval("cform.brandname"+i);
    obj.value=Trim(cform.brandcodetemp.value);
    if(obj1.value == "")
    	obj1.value=objtemp;
  }
}

function allcheckselect(){
	var allcheck = cform.allcheck.checked;
	var alldatafile = document.getElementsByName('brandcodes');
	var length = alldatafile.length;
	if(allcheck){
		for(var i = 0 ; i < length;i++){
			alldatafile[i].checked = true;
		}
	}else{
		for(var i = 0 ; i < length;i++){
			alldatafile[i].checked = false;
		}	
	}
}

</script>
</head>
<body>
<form name="cform" method="post" action="../../Dispatcher"  target="_self">
    <input type="hidden" name="pagename" value="prodbrandsummary">
    <input type="hidden" name="actionname">
    <input type="hidden" name="pageaction">
    <input type="hidden" name="nullstring">
<%@ include file="/inc/PageLocation.inc" %>
<table width="100%" cellspacing="0" border="0" cellpadding="0">
  <tr> 
    <td> 
      <table width="100%" border="0" cellspacing="0">
        <tr> 
          <td class="summary_top" width="10%" colspan="3" ></td>
        </tr>
        <%@ include file="/inc/SummarySearch.inc" %>
      </table>
    </td>
  </tr>
  <tr> 
    <td> 
      <table width="100%" border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center">
       
          <tr class="deepblue-left"> 
            <td width="22" class="title_center"><input type="checkbox" name="allcheck" class="normalradio" onclick="allcheckselect();"></td>
            <td width="80" class="title_center"><%=label.getLabelName("L_BrandCode")%><span class="red">*</span></td>
          	<td class="title_center" width="150"><%=label.getLabelName("L_Name")%> <span class="red">*</span></td>
            <span id="olddetail">
          </tr>
           <%
            Vector prodbrandsummary=(Vector)pageContext.getAttribute("prodbrandsummary");
            if(prodbrandsummary==null)
              prodbrandsummary=new Vector();
            int i=1;
            int org =0;;
            String strClassType="none";
          %>
          <logic:iterate id="prodbrandsummaryitem" collection="<%= prodbrandsummary %>" >
          <%
          	HashMap PSMap = (HashMap)pageContext.getAttribute("prodbrandsummaryitem");
            Integer oColIndexLang=new Integer(i);
            if(i%2==0)
              strClassType="td-listrom";
            else
              strClassType="none";
            i++;
          %>
          <tr onMouseOver="this.className='tr-over'" onMouseOut="this.className='<%=JspHelper.filterNull(strClassType)%>'"  class="<%=JspHelper.filterNull(strClassType)%>"> 
            <td class="none"> 
            	<% org = ((Integer)PSMap.get("orgid")).intValue(); 
             	if(org == 1&&orgid!=1) {
           		%>&nbsp;
           		<input type="hidden" name="brandcodes" id="brandcodes<%=JspHelper.filterNull(i-1)%>"/>
           		<%} else {%>
              <input type="checkbox" name="brandcodes" id="brandcodes<%=JspHelper.filterNull(i-1)%>" value="<custom:write name="prodbrandsummaryitem" property="brandcode"/>" class="normalradio" />
              	<% }%>
            </td>
            <td>&nbsp;<custom:write name="prodbrandsummaryitem" property="brandcode"/></td>
            <td>
          	<% org = ((Integer)PSMap.get("orgid")).intValue(); 
             	if(org == 1&&orgid!=1) {
             	%>
             	<custom:write name="prodbrandsummaryitem" property="brandname"/>
           		
           		<%} else {%>
            <custom:text name="prodbrandsummaryitem" command="notnull" module="PCM" label="L_Name" size="40" colIndex="<%=oColIndexLang%>" property="brandname" isFirstMLC="true" multiLangType="brandname"  entityId="brandcode" contentId="productbrandid"   needMLC="true"   />
            
            <a onclick="page_mulilang('brandname','L_Name','<%=oColIndexLang%>','need','<custom:write name="prodbrandsummaryitem" property="brandcode" />',<custom:write name="userinfo" scope="session" property="orgid" />);"><custom:button type="3" label="L_Ln" imgsrc="ln.gif" border="0"/></a> 
           <% }%>
            </td>
            
          </tr>
          </logic:iterate>
          </span>
          <input type=hidden name=nums value="<%=JspHelper.filterNull(prodbrandsummary.size())%>">
          <input type=hidden name=numrows value="<%=LangNums*(JspHelper.filterNull(prodbrandsummary.size())+1)%>">
          <span id="newdetail">
          <tr class="none"> 
            <td>&nbsp; </td>
            <td> 
              <input type="text" name="brandcodetemp" dataType="string" command="notnull" label="<%=label.getLabelName("L_BrandCode",false)%>" module="PCM" size="20"/>
            </td>
            <td> 
           
            <custom:text  command="notnull" module="PCM" label="L_Name" size="40" property="brandname" isFirstMLC="true" multiLangType="brandname"  entityId="brandcode" contentId="productbrandid"   needMLC="true" onchange="javascript:page_copydesc();"  />
            
            <a onclick="page_mulilang('brandname','L_Name','0','need','-1',<custom:write name="userinfo" scope="session" property="orgid" />);"><custom:button type="3" label="L_Ln" imgsrc="ln.gif" border="0"/></a> 
            
               </td>
            
          </tr>
        </span>
      </table>
      <table width="100%" cellspacing="0" cellpadding="0">
        <tr> 
          <td class="summary_top"></td>
        </tr>
        <tr> 
          <td class="td_center">
            <a onclick="page_add();"><custom:button type="1" label="L_Add" imgsrc="add.gif" border="0" style="width:60" privilegeCode="MB-PP01"/></a>
             <a onclick="page_save();"><custom:button type="1" label="L_Save" imgsrc="cancel.gif" border="0" style="width:60" privilegeCode="MB-PP02"/></a>
            <a onclick="page_delete();"><custom:button type="1" label="L_Delete" imgsrc="delete.gif" border="0" style="width:60" privilegeCode="MB-PP03"/></a>
            </td>
           
        </tr>
      </table>
    </td>
  </tr>
</table>
</form>
</body>
</html>


